package com.example.shop.controller;

import com.example.shop.model.req.CreateOrderDTO;
import com.example.shop.model.req.ModifyOrderDTO;
import com.example.shop.model.resp.OrderDetail;
import com.example.shop.service.OrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author qwer3
 * @version 1.0.0
 * @create 2025/11/2 11:14
 */
@RestController
@RequestMapping("/api/order/v2")
@RequiredArgsConstructor
public class OrderController {
    private final OrderService orderService;

    @PostMapping("/buy")
    public void createOrder(@RequestBody CreateOrderDTO createOrderDTO) {
        orderService.createOrder(createOrderDTO);
    }

    @GetMapping("/list")
    public List<OrderDetail> getOrderList() {
        return orderService.getOrderList();
    }

    @PostMapping("/modify")
    public void modifyOrderStatus(@RequestBody ModifyOrderDTO modifyOrderDTO) {
        orderService.modifyOrderStatus(modifyOrderDTO);
        System.out.println(modifyOrderDTO);
    }
}
